package com.kjzy.api.fallback;

import com.kjzy.api.client.UserClient;
import com.kjzy.api.pojo.User;
import org.springframework.cloud.openfeign.FallbackFactory;


public class UserClientFallbackFactory implements FallbackFactory<UserClient> {
    public UserClient create(final Throwable cause) {
        // 创建UserClient接口实现类，实现其中的方法，编写失败降级的处理逻辑
        return new UserClient() {
            public User getUserById(int id) {
                // 记录异常信息，可以返回空或抛出异常
                System.out.println("走fallback逻辑");
                return null;
            }
        };
    }

}
